package com.wbtech.ums.dao;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
 * 
 * DBHelper 类描述： 创建数据库
 * 
 */
public class DBHelper extends SQLiteOpenHelper {

	/**
	 * 数据库名称
	 * 
	 */
	private static final String DB_NAME = "cobub_ums";
	
	/**
	 * 数据库版本号
	 */
	private static final int DB_VERSION = 2;
	
	/**
	 * 创建event 表
	 */
	private static final String CREATE_EVENT_TABLE = "create table event ("
			+ "event_id varchar,"
			+ "time varchar,"
			+ "version varchar, "
			+ "appkey   varchar, "
			+ "activity  varchar," 
			+ "label  varchar," 
			+ "acc  varchar )";
	/**
	 * 创建 activity表  
	 */
	private static final String CREATE_ACTIVITY_TABLE = "create table activity ("
			+ "session_id varchar,"
			+ "start_millis varchar," 
			+ "end_millis varchar, "
			+ "duration varchar, "
			+ "version varchar,"
			+ "activities varchar,"
			+ "appkey varchar)";

	/**
	 * 创建 error表
	 */
	private static final String CREATE_ERROR_TABLE = "create table error ("
			+ "stacktrace varchar,"
			+ "time varchar,"
			+ "version varchar, "
			+ "activity varchar, "
			+ "appkey varchar,"
			+ "os_version varchar,"
			+ "deviceid varchar)";
	
	/**
	 * 创建 client_data 表
	 * 
	 */
	private static final String CREATE_CLIENT_DATA_TABLE = "create table client_data ("
			+ "os_version varchar,"+ "platform varchar,"+ "language varchar, "+ "deviceid varchar, "+ "appkey varchar,"+ "resolution varchar,"
			+ "ismobiledevice varchar,"+ "phonetype varchar,"+ "imsi varchar,"+ "network varchar,"+ "time varchar,"
			+ "version varchar,"+ "userid varchar,"+ "mccmnc varchar,"+ "cellid varchar,"+ "lac varchar,"
			+ "modulename varchar,"+ "devicename varchar,"+ "wifimac varchar,"+ "havebt varchar,"+ "havewifi varchar,"
			+ "havegps varchar,"+ "havegravity varchar,"+ "latitude varchar,"+ "longitude varchar)";
	
	
	/**
	 * 创建 tags 表
	 */
	private static final String CREATE_TAGS_TABLE = "create table tags ("
			+ "tags varchar,"
			+ "deviceid varchar,"
			+ "productkey varchar)";
	
	
	public DBHelper(Context context) {
		super(context, DB_NAME, null, DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(CREATE_EVENT_TABLE);
		db.execSQL(CREATE_ACTIVITY_TABLE);
		db.execSQL(CREATE_ERROR_TABLE);
		db.execSQL(CREATE_CLIENT_DATA_TABLE);
		db.execSQL(CREATE_TAGS_TABLE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

	}

}
